// AUTO GENERATED CODE!
// CODE GENERATOR WILL NOT PRESERVE MANUAL CHANGES TO THIS CODE!
// 

// MIT License (MIT)
// 
// Copyright (c) 2014 K Ercan Turkarslan
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// 


using System;

namespace Mios.Generated.ServiceFiles
{
    // Generated from S_Dimming1.xml
    
    public class Dimming1Service : MiosService
    {
        #region LoadLevelTarget : Byte;
        private Byte? _mLoadLevelTarget;
        
        public Byte LoadLevelTarget
        {
            get
            {
                return _mLoadLevelTarget ?? GetLoadLevelTarget();
            }
        }
        
        #region Action SetLoadLevelTarget(Byte newLoadlevelTarget) : String;
        public String SetLoadLevelTarget(Byte newLoadlevelTarget)
        {
            if(newLoadlevelTarget > 100)
                throw new ArgumentOutOfRangeException("newLoadlevelTarget");
            
            return Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetLoadLevelTarget",
                String.Format("newLoadlevelTarget={0}", ToLuup(_mLoadLevelTarget = newLoadlevelTarget)));
        }
        #endregion Action SetLoadLevelTarget
        
        #region Action GetLoadLevelTarget() : Byte;
        public Byte GetLoadLevelTarget()
        {
            _mLoadLevelTarget = FromLuupByte(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "LoadLevelTarget"));
            
            return _mLoadLevelTarget.Value;
        }
        #endregion Action GetLoadLevelTarget
        
        #endregion
        
        #region LoadLevelStatus : Byte;
        private Byte? _mLoadLevelStatus;
        
        public Byte LoadLevelStatus
        {
            get
            {
                return _mLoadLevelStatus ?? GetLoadLevelStatus();
            }
        }
        
        #region Action SetLoadLevelStatus(Byte newLoadLevelStatus) : String;
        public String SetLoadLevelStatus(Byte newLoadLevelStatus)
        {
            if(newLoadLevelStatus > 100)
                throw new ArgumentOutOfRangeException("newLoadLevelStatus");
            
            return Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetLoadLevelStatus",
                String.Format("newLoadLevelStatus={0}", ToLuup(_mLoadLevelStatus = newLoadLevelStatus)));
        }
        #endregion Action SetLoadLevelStatus
        
        #region Action GetLoadLevelStatus() : Byte;
        public Byte GetLoadLevelStatus()
        {
            _mLoadLevelStatus = FromLuupByte(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "LoadLevelStatus"));
            
            return _mLoadLevelStatus.Value;
        }
        #endregion Action GetLoadLevelStatus
        
        #endregion
        
        #region MinLevel : Byte;
        private Byte? _mMinLevel;
        
        public Byte MinLevel
        {
            get
            {
                return _mMinLevel ?? GetMinLevel();
            }
        }
        
        #region Action SetMinLevel(Byte newMinLevel) : String;
        public String SetMinLevel(Byte newMinLevel)
        {
            if(newMinLevel > 100)
                throw new ArgumentOutOfRangeException("newMinLevel");
            
            return Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetMinLevel",
                String.Format("newMinLevel={0}", ToLuup(_mMinLevel = newMinLevel)));
        }
        #endregion Action SetMinLevel
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action GetMinLevel() : Byte;
        public Byte GetMinLevel()
        {
            _mMinLevel = FromLuupByte(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "MinLevel"));
            
            return _mMinLevel.Value;
        }
        #endregion Action GetMinLevel
        
        #endregion
        
        #region OnEffectLevel : Byte;
        private Byte? _mOnEffectLevel;
        
        public Byte OnEffectLevel
        {
            get
            {
                return _mOnEffectLevel ?? GetOnEffectLevel();
            }
        }
        
        #region Action SetOnEffectLevel(Byte newOnEffectLevel) : String;
        public String SetOnEffectLevel(Byte newOnEffectLevel)
        {
            if(newOnEffectLevel > 100)
                throw new ArgumentOutOfRangeException("newOnEffectLevel");
            
            return Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetOnEffectLevel",
                String.Format("newOnEffectLevel={0}", ToLuup(_mOnEffectLevel = newOnEffectLevel)));
        }
        #endregion Action SetOnEffectLevel
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action GetOnEffectLevel() : Byte;
        public Byte GetOnEffectLevel()
        {
            _mOnEffectLevel = FromLuupByte(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "OnEffectLevel"));
            
            return _mOnEffectLevel.Value;
        }
        #endregion Action GetOnEffectLevel
        
        #endregion
        
        #region OnEffect : String;
        private String _mOnEffect;
        
        public String OnEffect
        {
            get
            {
                return _mOnEffect ?? GetOnEffect();
            }
        }
        
        #region Action SetOnEffect(String newOnEffect) : String;
        public String SetOnEffect(String newOnEffect)
        {
            if (String.IsNullOrEmpty(newOnEffect))
                throw new ArgumentNullException("newOnEffect");
            
            switch(newOnEffect)
            {
                case "OnEffectLevel":
                case "LastSetting":
                case "Default":
                    break;
                
                default:
                    throw new ArgumentOutOfRangeException("newOnEffect");
            }
            
            return Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetOnEffect",
                String.Format("newOnEffect={0}", ToLuup(_mOnEffect = newOnEffect)));
        }
        #endregion Action SetOnEffect
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action GetOnEffect() : String;
        public String GetOnEffect()
        {
            _mOnEffect = FromLuupString(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "OnEffect"));
            
            return _mOnEffect;
        }
        #endregion Action GetOnEffect
        
        #endregion
        
        #region ValidOutputValues : String;
        private String _mValidOutputValues;
        
        public String ValidOutputValues
        {
            get
            {
                return _mValidOutputValues ?? GetValidOutputValues();
            }
        }
        
        // WARNING: Service Description File does not contain any Get Action with a
        // argument related to this State Variable.
        // 
        // This may be due to a typo while defining the Get Action or state variable.
        // This may also be intentional. Code generator assumes this was a mistake and
        // generates this Get Action.
        
        #region Action GetValidOutputValues() : String;
        public String GetValidOutputValues()
        {
            _mValidOutputValues = FromLuupString(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "ValidOutputValues"));
            
            return _mValidOutputValues;
        }
        #endregion Action GetValidOutputValues
        
        #endregion
        
        #region StepDelta : Byte;
        private Byte? _mStepDelta;
        
        public Byte StepDelta
        {
            get
            {
                return _mStepDelta ?? GetStepDelta();
            }
        }
        
        #region Action SetStepDelta(Byte newStepDelta) : String;
        public String SetStepDelta(Byte newStepDelta)
        {
            if((newStepDelta < 1) || (newStepDelta > 100))
                throw new ArgumentOutOfRangeException("newStepDelta");
            
            return Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetStepDelta",
                String.Format("newStepDelta={0}", ToLuup(_mStepDelta = newStepDelta)));
        }
        #endregion Action SetStepDelta
        
        #region Action GetStepDelta() : Byte;
        public Byte GetStepDelta()
        {
            _mStepDelta = FromLuupByte(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "StepDelta"));
            
            return _mStepDelta.Value;
        }
        #endregion Action GetStepDelta
        
        #endregion
        
        #region RampRate : Byte;
        private Byte? _mRampRate;
        
        public Byte RampRate
        {
            get
            {
                return _mRampRate ?? GetRampRate();
            }
        }
        
        #region Action SetRampRate(Byte newRampRate) : String;
        public String SetRampRate(Byte newRampRate)
        {
            if(newRampRate > 100)
                throw new ArgumentOutOfRangeException("newRampRate");
            
            return Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetRampRate",
                String.Format("newRampRate={0}", ToLuup(_mRampRate = newRampRate)));
        }
        #endregion Action SetRampRate
        
        #region Action GetRampRate() : Byte;
        public Byte GetRampRate()
        {
            _mRampRate = FromLuupByte(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "RampRate"));
            
            return _mRampRate.Value;
        }
        #endregion Action GetRampRate
        
        #endregion
        
        #region RampTime : UInt32;
        private UInt32? _mRampTime;
        
        public UInt32 RampTime
        {
            get
            {
                return _mRampTime ?? GetRampTime();
            }
        }
        
        #region Action SetRampTime(UInt32 newRampTime) : String;
        public String SetRampTime(UInt32 newRampTime)
        {
            return Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetRampTime",
                String.Format("newRampTime={0}", ToLuup(_mRampTime = newRampTime)));
        }
        #endregion Action SetRampTime
        
        #region Action GetRampTime() : UInt32;
        public UInt32 GetRampTime()
        {
            _mRampTime = FromLuupUInt32(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "RampTime"));
            
            return _mRampTime.Value;
        }
        #endregion Action GetRampTime
        
        #endregion
        
        #region IsRamping : Boolean;
        private Boolean? _mIsRamping;
        
        public Boolean IsRamping
        {
            get
            {
                return _mIsRamping ?? GetIsRamping();
            }
        }
        
        #region Action GetIsRamping() : Boolean;
        public Boolean GetIsRamping()
        {
            _mIsRamping = FromLuupBoolean(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "IsRamping"));
            
            return _mIsRamping.Value;
        }
        #endregion Action GetIsRamping
        
        #endregion
        
        #region RampPaused : Boolean;
        private Boolean? _mRampPaused;
        
        public Boolean RampPaused
        {
            get
            {
                return _mRampPaused ?? GetRampPaused();
            }
        }
        
        #region Action GetRampPaused() : Boolean;
        public Boolean GetRampPaused()
        {
            _mRampPaused = FromLuupBoolean(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "RampPaused"));
            
            return _mRampPaused.Value;
        }
        #endregion Action GetRampPaused
        
        #endregion
        
        
        #region Action GetOnEffectParameters(out String retOnEffect, out Byte retOnEffectLevel)
        public void GetOnEffectParameters(out String retOnEffect, out Byte retOnEffectLevel)
        {
            // WARNING: This version of code generator does not know how to generate Http Luup requests with out variables.
            // Below generated code may not function properly!
            // 
            
            retOnEffect = default(String);
            retOnEffectLevel = default(Byte);
            
            Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "GetOnEffectParameters"
                , String.Format("retOnEffect={0}", ToLuup(retOnEffect))
                , String.Format("retOnEffectLevel={0}", ToLuup(retOnEffectLevel))
                ); // Engine.Luup_CallAction
        }
        #endregion Action GetOnEffectParameters
        
        #region Action StepUp()
        public void StepUp()
        {
            Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "StepUp");
        }
        #endregion Action StepUp
        
        #region Action StepDown()
        public void StepDown()
        {
            Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "StepDown");
        }
        #endregion Action StepDown
        
        #region Action StartRampUp()
        public void StartRampUp()
        {
            Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "StartRampUp");
        }
        #endregion Action StartRampUp
        
        #region Action StartRampDown()
        public void StartRampDown()
        {
            Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "StartRampDown");
        }
        #endregion Action StartRampDown
        
        #region Action StopRamp()
        public void StopRamp()
        {
            Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "StopRamp");
        }
        #endregion Action StopRamp
        
        #region Action StartRampToLevel(Byte newLoadLevelTarget, UInt32 newRampTime)
        public void StartRampToLevel(Byte newLoadLevelTarget, UInt32 newRampTime)
        {
            Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "StartRampToLevel"
                , String.Format("newLoadLevelTarget={0}", ToLuup(newLoadLevelTarget))
                , String.Format("newRampTime={0}", ToLuup(newRampTime))
                ); // Engine.Luup_CallAction
        }
        #endregion Action StartRampToLevel
        
        #region Action PauseRamp()
        public void PauseRamp()
        {
            Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "PauseRamp");
        }
        #endregion Action PauseRamp
        
        #region Action ResumeRamp()
        public void ResumeRamp()
        {
            Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "ResumeRamp");
        }
        #endregion Action ResumeRamp
        
        
        #region Method SetVariable(String name, String value) : Boolean;
        internal override Boolean SetVariable(String name, String value)
        {
            switch(name)
            {
                case "IsRamping":
                    _mIsRamping = FromLuupBoolean(value); return true;
                case "LoadLevelStatus":
                    _mLoadLevelStatus = FromLuupByte(value); return true;
                case "LoadLevelTarget":
                    _mLoadLevelTarget = FromLuupByte(value); return true;
                case "MinLevel":
                    _mMinLevel = FromLuupByte(value); return true;
                case "OnEffect":
                    _mOnEffect = FromLuupString(value); return true;
                case "OnEffectLevel":
                    _mOnEffectLevel = FromLuupByte(value); return true;
                case "RampPaused":
                    _mRampPaused = FromLuupBoolean(value); return true;
                case "RampRate":
                    _mRampRate = FromLuupByte(value); return true;
                case "RampTime":
                    _mRampTime = FromLuupUInt32(value); return true;
                case "StepDelta":
                    _mStepDelta = FromLuupByte(value); return true;
                case "ValidOutputValues":
                    _mValidOutputValues = FromLuupString(value); return true;
                default:
                    return false;
            }
        }
        #endregion Method SetVariable
        
        public Dimming1Service(MiosEngine engine, UInt32 deviceId, String serviceId)
            : base(engine, deviceId, serviceId)
        {
            
        } //End Constructor
    } //End of class
} //End of Namespace

